package com.yanqu.road.server.cmd.activity.mammonhall;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.activity.MammonHallProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;

@Cmd(code = Protocol.C_MAMMON_HALL_SYNC_USER_BASE_DATA, desc = "财神殿-数据同步-玩家基础数据")
public class CrossMammonHallSyncUserDataCmd extends CrossCommand {

    List<MammonHallProto.CrossMammonHallSyncUserBaseInfoTemp> list;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        MammonHallProto.CrossMammonHallSyncUserBaseInfoRespMsg reqMsg = MammonHallProto.CrossMammonHallSyncUserBaseInfoRespMsg.parseFrom(packet.getBytes());
        list = reqMsg.getInfoTempList();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        for (MammonHallProto.CrossMammonHallSyncUserBaseInfoTemp infoTemp : list) {
            CrossUserMgr.updateUserBaseInfo(infoTemp.getUserId(), PlayerBasePb.parseToUserBaseInfo(infoTemp.getUserInfo()));
        }
    }

    @Override
    public void sendData() {

    }
}
